<!--
 * @Author: White
 * @description: 主播电台
 * @LastEditTime: 2021-08-24 22:01:19
-->

<template>
  <div class="card-wrapper-loading"
    :style="{ 'background': theme.color }"
    v-show="loading"
    v-loading="loading"
    element-loading-text="载入中..."
    element-loading-spinner="el-icon-loading">
  </div>
  <div class="new-music" :style="{ 'color': theme.text }">
    <div class="music-title">
      <h3>主播电台</h3>
      <i class="el-icon-arrow-right"></i>
    </div>
    <div class="music-content">
      <div class="music-item" v-for="(item, index) in list" :key="index">
        <img :src="item.picUrl" alt="" />
        <div class="music-text">
          <p class="title">{{ item.rcmdText }}</p>
          <p class="desc">{{ item.name }}</p>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { useStore } from 'vuex'
import { reactive, onMounted, computed, toRefs } from 'vue'
import { getRadio } from '@/api/music'

export default {
  setup () {
    const store = useStore()
    const theme = computed(() => store.state.theme)
    const state = reactive({
      loading: false,
      list: []
    })
    onMounted(async () => {
      state.loading = true
      const res = await getRadio()
      if (res.data.code === 200) {
        state.list = res.data.data
        state.loading = false
      }
    })
    return {
      ...toRefs(state),
      theme
    }
  }
}
</script>

<style lang="scss" scoped>
.new-music {
  .music-title {
    height: 30px;
    display: flex;
    align-items: center;
    h3 {
      line-height: 30px;
      font-size: 16px;
      font-weight: 700;
      text-decoration: none;
    }
  }
  .music-content {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    .music-item {
      width: 46%;
      display: flex;
      align-items: center;
      padding: 10px 0px;
      border-bottom: 1px solid #ededed;
      img {
        width: 100px;
        height: 100px;
        border-radius: 10px;
        margin-right: 30px;
      }
      .music-text {
        .title {
          font-size: 14px;
          font-weight: 700;
          margin-bottom: 10px;
          display: flex;
          align-items: center;
          overflow: hidden;
          white-space: nowrap;
          text-overflow: ellipsis;
          word-break: break-all;
        }
        .desc {
          font-size: 13px;
          color: #666;
          overflow: hidden;
          white-space: nowrap;
          text-overflow: ellipsis;
          word-break: break-all;
        }
      }
    }
  }
}
</style>
